package com.net.xpay.core.domain;

import com.net.xpay.common.domain.User;
import com.net.xpay.common.enums.invoice.OpenInvoiceStatus;
import com.net.common.domain.CommonDomain;
import com.net.xpay.core.enums.BillPayMethod;
import com.net.xpay.core.enums.PayStatus;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.time.LocalDateTime;

/**
 * @author  on 24/03/2018.
 * 充值记录
 * 后续可以添加其它充值的优惠信息在这里(比如套餐信息之类的在这里)
 */
@Getter
@Setter
@NoArgsConstructor
public class ChargeRecord extends CommonDomain {
    @ApiModelProperty(notes = "用户编号")
    private Long userId;

    @ApiModelProperty(notes = "合伙人id")
    private Long partnerId;

    @ApiModelProperty(notes = "父级合伙人id")
    private Long fatherPartnerId;

    @ApiModelProperty(notes = "支付宝账号id")
    private Long alipayUserId;

    @ApiModelProperty(notes = "开票状态")
    private OpenInvoiceStatus openInvoiceStatus;

    @ApiModelProperty(notes = "付款方支付宝账号")
    private String alipayNickName;

    @ApiModelProperty(notes = "明细外部订单号 必选  user_id + '_' + charge_record.id")
    private String outBizNo;

    @ApiModelProperty(notes = "导入的明细外部订单号 非必选")
    private String importBizNo;

    @ApiModelProperty(notes = "第三方回调地址 我们推送给第三方的")
    private String notifyUrl;

    @ApiModelProperty(notes = "绝对超时时间，格式为 yyyy-MM-dd HH:mm:ss 非必选")
    private LocalDateTime timeExpire;

    @ApiModelProperty(notes = "支付状态")
    private PayStatus payStatus;

    @ApiModelProperty(notes = "最后一次发起的付款链接")
    private String lastPayUrl;

    @ApiModelProperty(notes = "最后一次发起的移动端付款链接")
    private String lastMobilePayUrl;

    @ApiModelProperty(notes = "生成的移动端付款二维码")
    private String mobilePayQrCode;

    //充值金额
    @ApiModelProperty(notes = "充值的基础金额")
    private Long amount;

    @ApiModelProperty(notes = "支付方式")
    private BillPayMethod billPayMethod;

    @ApiModelProperty(notes = "收款方账号，传入支付宝账号或者支付宝uid test@taobao.com 必选")
    private String identity;

    @ApiModelProperty(notes = "1.当identity传入支付宝账号时，identity_type传ALIPAY_LOGON_ID 2.当当identity传入支付宝uid时，identity_type传ALIPAY_USER_ID 3.TAOBAO_NICKNAME 旺旺 必选")
    private String identityType;

    @ApiModelProperty(notes = "参与方真实姓名，如果非空，将校验收款支付宝账号姓名一致性。当identity_type传ALIPAY_LOGON_ID时此字段必选")
    private String name;

    @ApiModelProperty(notes = "完成时间")
    private LocalDateTime endTime;

    @ApiModelProperty(notes = "支付宝发起支付后返回的 支付宝批次订单号")
    private String batchTransId;

    @ApiModelProperty(notes = "支付宝系统内部明细单号")
    private String detailId;

    @ApiModelProperty(notes = "明细失败错误码")
    private String errorCode;

    @ApiModelProperty(notes = "明细失败错误原因")
    private String errorMsg;

    @ApiModelProperty(notes = "备注")
    private String memo;

    public static ChargeRecord getInstance(User user) {
        ChargeRecord chargeRecord = new ChargeRecord();

        chargeRecord.setUserId(user.getId());
        chargeRecord.setPartnerId(user.getPartnerId());
        chargeRecord.setFatherPartnerId(user.getFatherPartnerId());
        chargeRecord.setPayStatus(PayStatus.WAIT_PAY);
        chargeRecord.setOpenInvoiceStatus(OpenInvoiceStatus.WAIT);
        chargeRecord.setAmount(0L);
        chargeRecord.setBillPayMethod(null);
        chargeRecord.setEndTime(null);
        return chargeRecord;
    }

    public static ChargeRecord getInstance() {
        return new ChargeRecord();
    }


}
